#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 2e5 + 10;
ll n, k;


ll f(ll x) {
    return x*x+2*x+3;
}
int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    cin >> n;
    cout << f(f(f(n)+n) + f(f(n))) << endl;
    return 0;
}